﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Model;

namespace BusinnessLogic
{
    public class ManageProducts
    {
        public List<Sprint> PopulateSprintlist(int prodid)
        {
            DataLayer.dlsprintlist DLsprintlistfiller = new DataLayer.dlsprintlist();
            DataSet dtso = DLsprintlistfiller.SprintList(prodid);

            List<Sprint> sprintlist = new List<Sprint>();


            for (int i = 0; i < dtso.Tables[0].Rows.Count; i++)
            {
               int sprintid = int.Parse(dtso.Tables[0].Rows[i]["SprintId"].ToString());
               string sprinttitel = dtso.Tables[0].Rows[i]["Titel"].ToString();
                
                Sprint eensprint = new Sprint(sprintid,sprinttitel);
                sprintlist.Add(eensprint);

            }
            return sprintlist;
        }

        public List<Product> PopulateProductlist(int prodid)
        {
            DataLayer.dlproduct DLproductfiller = new DataLayer.dlproduct();
            DataSet dts = DLproductfiller.ProductList(prodid);

            List<Product> productlist = new List<Product>();


            for (int i = 0; i < dts.Tables[0].Rows.Count; i++)
            {
                int productid = int.Parse(dts.Tables[0].Rows[0]["Productid"].ToString());
                string productname = dts.Tables[0].Rows[i]["Name"].ToString();
                string productstatus = dts.Tables[0].Rows[i]["Status"].ToString();
                
                Product eenproduct = new Product(productid, productname, productstatus);
                productlist.Add(eenproduct);

            }
            return productlist;
        }
    }
}
